using System.Text;

namespace WinFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        bool IsPrime(int number)
        {
            if (number <= 1) return false;
            if (number == 2) return true;
            if (number % 2 == 0) return false;
            var boundary = (int)Math.Floor(Math.Sqrt(number));
            for (int i = 3; i <= boundary; i += 2)
            {
                if (number % i == 0)
                    return false;
            }
            return true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string input = textBox1.Text;
            string[] inputArray = input.Split(' ');
            int[] numbers = Array.ConvertAll(inputArray, int.Parse);
            int max = numbers.Max();
            int min = numbers.Min();


            int count = 0;
            StringBuilder prime = new StringBuilder();
            for (int num = min; num <= max; num++)
            {
                if (IsPrime(num))
                {
                    prime.Append(num.ToString()+" ");
                    count++;

                    if (count % 10 == 0)
                    {
                        prime.AppendLine();
                    }
                }
            }
            label2.Text = prime.ToString();
        }
    }
}